package com.project.personal_blog.garbage_classification_management_system.service.Impl;

import com.project.personal_blog.garbage_classification_management_system.mapper.rootMapper;
import com.project.personal_blog.garbage_classification_management_system.pojo.User;
import com.project.personal_blog.garbage_classification_management_system.service.RootService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RootServiceImpl implements RootService {
    @Autowired
    private rootMapper rootMapper;

    // 删除所有用户
    @Override
    public boolean deleteUsers() {
        return rootMapper.deleteUsers();
    }

    // 查询所有用户
    @Override
    public List<User> selectUsers() {
        return rootMapper.selectUsers();
    }

    // 根据用户名查询用户
    @Override
    public User selectByUsername(String username) {
        return rootMapper.selectUserByUsername(username);
    }

    // 根据id查询用户
    @Override
    public User selectById(Integer id) {
        return rootMapper.selectUserById(id);
    }

    // 根据电话号码查询用户
    @Override
    public User selectByPhoneNumber(String phoneNumber) {
        return rootMapper.selectUserByPhoneNumber(phoneNumber);
    }

    // 根据邮箱查询用户
    @Override
    public User selectByEmail(String email) {
        return rootMapper.selectUserByEmail(email);
    }

    // 添加用户
    @Override
    public User addUser(User user) {
        return rootMapper.addUser(user);
    }

    // 删除用户
    @Override
    public boolean deleteUser(Integer id) {
        return rootMapper.deleteUser(id);
    }

    // 更新用户
    @Override
    public User updateUser(User user) {
        return rootMapper.updateUser(user);
    }

    // 分页查询用户
    @Override
    public boolean pageUser(Integer pageNumber, Integer pageSize) {
        return rootMapper.PageUser(pageNumber, pageSize);
    }

    // 根据id进行排序
    @Override
    public boolean sortById(Integer id1, Integer id2) {
        return rootMapper.sortUserById(id1, id2);
    }

    // 根据名字进行排序
    @Override
    public boolean sortByName(String name1, String name2) {
        return rootMapper.sortUserByName(name1, name2);
    }

    // 根据电话号码进行排序
    @Override
    public boolean sortByPhoneNumber(String phoneNumber1, String phoneNumber2) {
        return rootMapper.sortUserByPhoneNumber(phoneNumber1, phoneNumber2);
    }

    // 根据邮箱进行排序
    @Override
    public boolean sortByEmail(String email1, String email2) {
        return rootMapper.sortUserByEmail(email1, email2);
    }
}